package com.txzt.gaea.business.fund.service.impl;

import com.txzt.gaea.business.fund.domain.model.FundIssued;
import com.txzt.gaea.business.fund.service.IFundIssuedService;
import com.txzt.gaea.common.base.service.impl.BaseServiceImpl;
import com.txzt.gaea.common.enums.FundIssuedStatus;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FundIssuedServiceImpl extends BaseServiceImpl<FundIssued> implements IFundIssuedService {

    @Override
    public int add(FundIssued fundIssued){
        List<FundIssued> fundIssuedList = sqlManager.query(FundIssued.class)
                .andEq("project_id",fundIssued.getProjectId())
                .select();
        if (1 <= fundIssuedList.size()){
            return 99;
        }
        return this.save(fundIssued);
    }

    @Override
    public int arrived(FundIssued fundIssued){
        int count = sqlManager.query(FundIssued.class)
                .andEq("id",fundIssued.getId())
                .updateSelective(fundIssued);
        return count;
    }

}
